from os import cpu_count
from matplotlib import markers
import matplotlib.pyplot as plt
import numpy as np

nx_time=[]
single_core_time=[]
gpu_time=[]
x_axis=[]


## read data
with open('res1.txt') as f:
    lines=f.readlines()
    for line in lines:
        items=line.split()
        x_axis.append(float(items[0]))
        nx_time.append(float(items[1]))
        gpu_time.append(float(items[2]))

with open('res.txt') as f:
    lines=f.readlines()
    for line in lines:
        items=line.split()
        single_core_time.append(float(items[0]))

ax=plt.axes()

## draw lines
nx_line=ax.plot(x_axis,nx_time,label="AVX 512")
gpu_line=ax.plot(x_axis,gpu_time,label="GPU")
cpu_len=len(single_core_time)
cpu_line=ax.plot(x_axis[:cpu_len],single_core_time,label="Normal")

## set x-y limitation
ax.set_xlim((0,2000))
ax.set_ylim((0,20))

## add labels
ax.set_xlabel("satellites")
ax.set_ylabel("time/s")

## add lengend
ax.legend()

x_ticks=range(0,2001,200)
ax.set_xticks(x_ticks)

ax.set_aspect(aspect='auto')
plt.savefig("./test.png")
